package com.alcloud.springplus.base;

/**
 * @className: ResponseCode
 * @description: 统一返回Code码
 * @date: 2018/12/5 9:20
 * @author: AllG
 * @updateRemark: 更新说明
 */
public enum ResponseCode {
    RESOURCE_NOT_FOUND(404, "资源不存在"),
    UNKOWN_EXCEPTION(500, "系统压力山大,请稍后重试！"),
    SUCCESS(200, "OK"),

    // 系统级别错误 600-1000
    INSERT_EXCEPTION(601, "数据新增失败！"),
    INSERT_BATCH_EXCEPTION(602, "数据新增失败！"),
    INSERT_DUPLICATE(603, "该数据已存在！"),
    UPDATE_EXCEPTION(604, "数据更新失败！"),
    DELETE_EXCEPTION(605, "数据删除失败！"),
    DISABLE_EXCEPTION(606, "使数据无效失败！"),
    SELECT_ONE_EXCEPTION(607, "数据获取失败！"),
    SELECT_EXCEPTION(608, "数据获取失败！"),
    SELECT_PAGINATION_EXCEPTION(609, "数据获取失败！"),
    UPDATE_EXCEPTION_NOSOURCE(610, "数据获取失败,没有源数据"),


    // 业务级别错误 1000-2000
    INVALID_SYSTEM_CLOCK(1001, "系统时间回调到当前时间之前的时间点，拒绝产生ID%d毫秒"),
    UNKOWN_WORKER_ID(1002, "无法获取IdWorker标识"),
    INVALID_WORKER_ID(1003, "无效IdWorker标识，%d > %d");


    private int code;
    private String message;

    private ResponseCode(int code, String message) {
        this.setCode(code);
        this.setMessage(message);
    }

    @Override
    public String toString() {
        return Integer.toString(getCode());
    }


    public String getMessage() {
        return message;
    }


    public void setMessage(String message) {
        this.message = message;
    }


    public int getCode() {
        return code;
    }


    public void setCode(int code) {
        this.code = code;
    }


}
